package ar.com.fiuba.ElectronicCircuitAnalyst.infrastructure.db4o.aspect;

import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;

import com.db4o.ObjectContainer;

@Aspect
public class TransactionContextAspect {
	
	private ObjectContainer objectContainer;
	
	@After("execution(* ar.com.fiuba.ElectronicCircuitAnalyst.application.api.*Service.make*(..))")
	public void doCommitAfterMake(){
		this.objectContainer.commit();
	}
	
	@After("execution(* ar.com.fiuba.ElectronicCircuitAnalyst.application.api.*Service.modify*(..))")
	public void doCommitAferUpdate(){
		this.objectContainer.commit();
	}
	
	@After("execution(* ar.com.fiuba.ElectronicCircuitAnalyst.application.api.*Service.remove*(..))")
	public void doCommitAferDelete(){
		this.objectContainer.commit();
	}
	
	/**
	 * @return the objectContainer
	 */
	public ObjectContainer getObjectContainer() {
		return objectContainer;
	}

	/**
	 * @param objectContainer the objectContainer to set
	 */
	public void setObjectContainer(ObjectContainer objectContainer) {
		this.objectContainer = objectContainer;
	}
	
}
